package com.simon.train.member.controller;

import com.simon.train.common.Result.Result;
import com.simon.train.common.context.LoginMemberContext;
import com.simon.train.common.vo.PageVO;
import com.simon.train.member.dto.TicketQueryDto;
import com.simon.train.member.service.TicketService;
import com.simon.train.member.vo.TicketQueryVO;
import jakarta.validation.Valid;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

@RestController
@RequestMapping("/ticket")
public class TicketController {

    @Autowired
    private TicketService ticketService;

    @GetMapping("/queryList")
    public Result<PageVO<TicketQueryVO>> query(@Valid TicketQueryDto req) {
        Result<PageVO<TicketQueryVO>> commonResp = new Result<>();
        req.setMemberId(LoginMemberContext.getId());
        PageVO<TicketQueryVO> pageResp = ticketService.QueryTicketList(req);
        commonResp.setContent(pageResp);
        return commonResp;
    }

}
